package com.gao.map;

import java.util.*;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class MapTest2 {
    /*
            需求：定义一个Map集合，
            添加完毕后，遍历结果
            格式如下：

            江苏省=南京市，扬州市，苏州市，无锡市，常州市
            ........
     */
    public static void main(String[] args) {
        Map<String, List<String>> map = new HashMap<>();
        List<String> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        List<String> list3 = new ArrayList<>();
        Collections.addAll(list1,"南京市","扬州市","苏州市","无锡市","常州市");
        Collections.addAll(list2,"武汉市","孝感市","十堰市","宜昌市","鄂州市");
        Collections.addAll(list3,"成都市","绵阳市","自贡市","攀枝花市","泸州市");
       map.put("江苏省",list1) ;
       map.put("湖北省",list2) ;
       map.put("四川省",list3) ;
         Set<Map.Entry<String, List<String>>> entries = map.entrySet();
        for (Map.Entry<String, List<String>> entry : entries) {
             String key = entry.getKey();
            System.out.print(key+"=");
             List<String> value = entry.getValue();
            for (int i = 0; i < value.size()-1; i++) {
                System.out.print(value.get(i)+",");
            }
            System.out.println(value.get(value.size() - 1));
        }

    }
}
